
package gene.core.util;

import gene.core.util.Vector2;
import gene.core.util.Sprite;
import gene.core.Core;
import gene.core.Component;
import gene.core.Scene;

/**
 *
 * @author callagun
 */
public abstract class Map extends Component {
 /*
 * id
 * tileset id
 * tile size
 * array.W
 * array.size
 * array
 *
 */
    public  static byte []     layer_tileset;
    public  static Sprite       tileset;
    public  static int         _tileW = 16;
    public  static int         _tileH = 16;
    public  static Camera      camera ;
    
    
    public Map(Scene screen, byte [][] tileset,int mapW, Sprite tiles, int tileW, int tileH) {
        super(screen);
        _tileH = tileH;
        _tileW = tileW;

        int mapH = tileset.length/mapW;
        int i=0;
        for(int x =0 ; x++ < mapW;){
            for(int y=0;y++ < mapH;){
               layer_tileset [i] = tileset[x][y];
               i++;
            }
        }
    }

    public abstract Vector2 getRefSlope(int id);

    //public abstract void draw();
    /*{

        byte[] off = {(byte) (VIEW_WINDOW_X % tileset.W), (byte) (VIEW_WINDOW_Y % tileset.H)};
        byte[] tilesize = {(byte) tileset.W, (byte) tileset.H};
        byte[] tmp = {0, 0};

        for (int scr_x = 0, x = (VIEW_WINDOW_X); x < (VIEW_WINDOW_X + VIEW_WINDOW_W) + 1; x += tileset.W) {

            for (int scr_y = 0, y = (VIEW_WINDOW_Y); y < (VIEW_WINDOW_Y + VIEW_WINDOW_H) + 1; y += tileset.H) {
                try {
                    //TODO CLASS SPRITE::PAINT FAZER BACKGROUND
                    tmp[0] = (byte) (y / tilesize[1]);
                    tmp[1] = (byte) (x / tilesize[0]);

                    buffer(scr_x - off[0], scr_y - off[1], layer_tileset[tmp[0]][tmp[1]]);
                    if( layer_object[tmp[0]][tmp[1]]!=null){
                    layer_object[tmp[0]][tmp[1]].update();
                    layer_object[tmp[0]][tmp[1]].setX(scr_x - off[0]);
                    layer_object[tmp[0]][tmp[1]].setY(scr_y - off[1]);
                    }
                } catch (Exception e) {
                }//{e.printStackTrace();}
                scr_y += tileset.H;
            }
            scr_x += tileset.W;
        }
        off = null;
        tilesize = null;
        tmp = null;
    }
*/
    

    

    
    



    

}